import { createRouter, createWebHashHistory } from "vue-router";
import routes from './routes.js';

const router = createRouter({
  history: createWebHashHistory(),
  routes
});
router.beforeEach((to, from, next) => {
  //如果路由需要跳转
  if (to.meta.isAuth) {
    //判断 如果school本地存储是qinghuadaxue的时候，可以进去
    if (localStorage.getItem('user') === 'admin') {
      next()  //放行
    } else {
      router.push('/login')
    }
  } else {
    // 否则，放行
    next()
  }
})
export default router;
